/*
 * Copyright (c) 2017 深圳市高德威技术有限公司  All rights reserved.
 *
 * serial.h
 *
 *  Created on: 2017年3月28日
 *      Author: chenshisheng
 */

#ifndef SERIAL_H_
#define SERIAL_H_

#include "main.h"
#include "ringbuffer.h"
#include "iostream.h"

#define SERIAL_RX_BUFFER_SIZE 1024
#define SERIAL_TX_BUFFER_SIZE 1024

typedef enum
{
    Serial_2,
    Serial_3,
    Serial_Max = Serial_3,
}Serial_t;

// 指定标准输入输出串口
#define STDIO_SERIAL Serial_2

// 和模块通信所用的串口
#define COM_SERIAL Serial_3

typedef void (* Serial_Callback_t)(void *ptr);

void Serial_Init(void);
void Serial_SetCallbacks(
        Serial_t serial,
        Serial_Callback_t onTxBegin,
        Serial_Callback_t onTxComplete,
        Serial_Callback_t onRx);
void Serial_SendByte(Serial_t serial, uint8_t b);
void Serial_Send(Serial_t serial, const void *data, unsigned int size);
Stream_t *Serial_ComStream(void);

#endif /* SERIAL_H_ */
